﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ObserverAndMediator
{
    /// <summary>
    /// 抽象的事件處理者
    /// </summary>
    public abstract class EventCustomer
    {
        //容納每個消費者能夠處理的級別
        private List<EventCustomType> customType = new List<EventCustomType>();

        /// <summary>
        /// 每個消費者都要聲明自己處理哪一類別的事件
        /// </summary>
        /// <param name="_type"></param>
        public EventCustomer(EventCustomType _type)
        {
            addCustomType(_type);
        }

        /// <summary>
        /// 每個消費者可以消費多個事件
        /// </summary>
        /// <param name="_type"></param>
        public void addCustomType(EventCustomType _type)
        {
            customType.Add(_type);
        }

        /// <summary>
        /// 得到自己的處理能力
        /// </summary>
        public List<EventCustomType> CustomType {
            get { return customType; }
        }

        /// <summary>
        /// 每個事件都要對事件進行聲明式消費
        /// </summary>
        /// <param name="events"></param>
        public abstract void exec(ProductEvent events);
    }
}
